<?php

namespace app\interfaces\model;

use think\Model;

class MemberDistributionOrder extends Model
{
    // 时间
    protected function getCreateTimeAttr($value, $data)
    {
        return date('Y-m-d', $data['create_time']);
    }

    /*
    * 分销订单和会员订单一对一 (适用于我的分销->分销商(已产生佣金))
    */
    public function memberOrder()
    {
        //确认收货和已完结的订单  状态为3,4
        return $this->hasOne('MemberOrder','shop_order_number','order_number')->where(['status' => ['in', '3,4' ]])->field('id,status,shop_order_number,pay_time,price,freight');
    }

    public function orderBrokerage()
    {
        return $this->hasOne('MemberOrder','shop_order_number','order_number')->field('id,status,shop_order_number,pay_time,price,freight');
    }
}
